﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WelfareLottery.DataManagement3D
{
    public partial class Add3DLotteryDataForm : Form
    {
        #region 构造函数
        public Add3DLotteryDataForm()
        {
            InitializeComponent();
        }
        #endregion

        #region 属性
        /// <summary>
        /// DAL类库实例
        /// </summary>
        private WLDAL.DALDataManagement3D dal = new WLDAL.DALDataManagement3D();
        #endregion

        #region 事件
        private void btnInsert_Click(object sender, EventArgs e)
        {
            WLEntity.Lottery3D entity = new WLEntity.Lottery3D();  //3D彩票实体
            int hundredNum = 0;  //百位数字
            int tenNum = 0;  //十位数字
            int bitsNum = 0;  //个位数字
            //过滤不符合数字格式的字符串
            if (!int.TryParse(txtHundredNum.UCText, out hundredNum))
            {
                MessageBox.Show("请在百位数字框中输入数字。", this.Text);
                txtHundredNum.UCText = "";
                return;
            }
            if (!int.TryParse(txtTenNum.UCText, out tenNum))
            {
                MessageBox.Show("请在十位数字框中输入数字。", this.Text);
                txtTenNum.UCText = "";
                return;
            }
            if (!int.TryParse(txtBitsNum.UCText, out bitsNum))
            {
                MessageBox.Show("请在个位数字框中输入数字。", this.Text);
                txtBitsNum.UCText = "";
                return;
            }
            //3D彩票记录实体赋值
            entity.LotteryPeriods = txtLotteryPeriods.Text;
            entity.HundredNum = hundredNum;
            entity.TenNum = tenNum;
            entity.BitsNum = bitsNum;
            try
            {
                if (dal.AddLotteryData(entity))
                {
                    MessageBox.Show("添加福彩记录成功。", this.Text);
                }
                else
                {
                    MessageBox.Show("添加福彩记录失败。", this.Text);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("添加福彩记录发生错误。" + ex.Message, this.Text);
            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();  //关闭本窗体
        }


        #endregion

        #region 方法

        #endregion
    }
}
